<?php
/**
 * Created by PhpStorm.
 * User: 4399-0661
 * Date: 15-5-9
 * Time: 下午2:06
 */

namespace test;


use Application\Base\mdlBase;

class libDatabaseTest extends \PHPUnit_Framework_TestCase
{
    public $tableName = "lib_log";

    public function testFactory()
    {
        \LibDatabase::factory('base');
    }

    public function testFetch()
    {
        $db = mdlBase::sdb('base');
        $data = [
            [
                'project' => 'golbal',
                'category' => 'db',
                'content' => 'dfsdfsd',
                'dateline' => time()
            ],
            [
                'project' => 'golbal',
                'category' => 'db',
                'content' => 'dfsdfsd',
                'dateline' => time()
            ]
        ];
        $db->multiInsert($this->tableName , $data);
        print_r($db->count($this->tableName));
        print_r($db->fetch($this->tableName));
        print_r($db->select($this->tableName));
        $db->update($this->tableName, ['category' => "db1"], 'id=1');
        print_r($db->select($this->tableName));

    }

    public function testPdo()
    {
        $db = \LibDatabase::factory('base');
        $data = [
            [
                'project' => 'golbal',
                'category' => 'db',
                'content' => 'dfsdfsd',
                'dateline' => time()
            ],
            [
                'project' => 'golbal',
                'category' => 'db',
                'content' => 'dfsdfsd',
                'dateline' => time()
            ]
        ];
        $db->multiInsert($this->tableName , $data);
        //$db->delete($this->tableName , "id=1");
        print_r($db->select($this->tableName));
    }
} 